<!-- 登录页面 -->
<script setup>
import { reactive, ref, computed } from 'vue'
import { useUserStoreWithOut } from '@/stores/modules/user'
import { useAppStoreWithOut } from '@/stores/modules/app'
const userStore = useUserStoreWithOut()
const appStore = useAppStoreWithOut()

const formData = reactive({
  username: '',
  password: '',
})

const title = computed(() => appStore.getTitle)

const signIn = () => {
  if (!formData.username || !formData.password) {
    ElMessage({
      type: 'error',
      message: '请输入用户名和密码！',
    })
    return
  }
  userStore.login(formData.username, formData.password)
}
</script>


<template>
  <div class="h-100">
    <ElScrollbar class="h-100">
      <div class="relative flex mx-auto min-h-100vh">
        <div class="flex-1 bg-353e54">
          <div class="flex items-center relative color-fff">
            <img src="@/assets/imgs/logo.png" alt="" class="w-48px h-48px m-r-10px" />
            <span class="text-20px font-bold">{{ title }}</span>
          </div>
          <div class="leftContent flex justify-center align_center">
            <TransitionGroup
              appear
              tag="div"
              enter-active-class="animate__animated animate__bounceInLeft"
            >
              <img src="@/assets/svgs/login-box-bg.svg" key="1" alt="" class="w-350px" />
              <div class="text-3xl color-fff" key="2">欢迎使用本系统</div>
            </TransitionGroup>
          </div>
        </div>
        <div class="flex-1 p-30px flex flex_column items-center justify-center">
          <div class="m-auto w-350px">
            <div class="text-center fz18 font-bold">登录</div>
            <ElForm ref="loginFormRef" :model="formData" label-position="top" size="large">
              <el-form-item label="账号" label-position="top">
                <el-input v-model="formData.username" />
              </el-form-item>
              <el-form-item label="密码" label-position="top">
                <el-input v-model="formData.password" type="password" show-password />
              </el-form-item>
            </ElForm>
            <ElButton @click="signIn" type="primary" class="w-full m-t-20px" size="large"
              >登录</ElButton
            >
            <div class="m-t-20px color-666">xxxxxxxxxxxxxxxx</div>
          </div>
        </div>
      </div>
    </ElScrollbar>
  </div>
</template>

<style scoped>
.leftContent {
  height: calc(100% - 60px);
}
</style>